package lab03.test01;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class Test {
    public static void main(String[] args) {
        //1.写文件
        //1.1字符流
        String path="D:\\hello.txt";
        BufferedWriter writer=null;

        try {
            writer = new BufferedWriter(new FileWriter(path));
            //BufferedWriter writer = new BufferedWriter(new FileWriter(path));
            //没有BufferedWriter writer=null;时
            writer.write("hello,world!");//一次写多个字符
            writer.newLine();//换行

            writer.write("010101011011001");
            writer.newLine();

            writer.write("bey!!!");

        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
